package com.zxjbyte.yiyi.module.system.service.oss.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zxjbyte.yiyi.framework.mybatis.service.impl.BaseServiceXImpl;
import com.zxjbyte.yiyi.module.system.domain.dto.oss.OssFileAddDTO;
import com.zxjbyte.yiyi.module.system.domain.entity.OssFilePO;
import com.zxjbyte.yiyi.module.system.mapper.oss.OssFileMapper;
import com.zxjbyte.yiyi.module.system.service.oss.IOssFileService;
import org.springframework.stereotype.Service;

/**
 * @Author zhangxingjia
 * @Date 2023/6/20 14:25
 * @Version: 1.0
 */
@Service
public class OssFileServiceImpl extends BaseServiceXImpl<OssFileMapper, OssFilePO> implements IOssFileService {

    @Override
    public void add(OssFileAddDTO addDto) {
        OssFilePO entity = new OssFilePO();
        entity.setContent(addDto.getContent());
        entity.setPath(addDto.getPath());
        save(entity);
    }

    @Override
    public OssFilePO getByPath(String path) {
        return lambdaQuery().eq(OssFilePO::getPath, path).one();
    }

    @Override
    public boolean deleteByPath(String path) {
        return remove(Wrappers.<OssFilePO>lambdaQuery().eq(OssFilePO::getPath, path));
    }
}
